import {
	getAddTeams
} from '@/api/product.js'
import {
	toast
} from "@/utils/common";
export default {
	data() {
		return {

		}
	},
	onLoad: function(res) {
		if (res.vipId) {
			getAddTeams(res.vipId).then(res => {
				if (res.data.flag) {
					toast(res.data.msg)
				} else {
					toast(res.data.msg)
				}
			})
		}
		wx.showShareMenu({
			withShareTicket: true,
			menus: ["shareAppMessage", "shareTimeline"]
		})
	},
	onShareAppMessage(res) {
		let that = this;
		let imageUrl = that.shareUrl || '';
		console.log("分享", res);
		if (res.from === 'button') {
			//这块需要传参，不然链接地址进去获取不到数据
			let id = uni.getStorageSync("vipId")
			let path = `/` + that.$scope.route + `?item=` + that.$scope.options.item + `&vipId=` + id;
			console.log(path);
			console.log("hhh", that.$scope);
			return {
				title: '商品分享~',
				path: path,
				imageUrl: imageUrl
			};
		}
		if (res.from === 'menu') {
			let id = uni.getStorageSync("vipId")
			let path = '/pages/home/home?id=' + id
			console.log("path", path);
			return {
				title: '金点科技',
				path,
				imageUrl: imageUrl
			};
		}
	},
	// 分享到朋友圈
	onShareTimeline() {
		return {
			title: '金点科技',
			path: '/pages/home/home',
			imageUrl: 'https://cdn.uviewui.com/uview/swiper/1.jpg'
		};
	},
	methods: {

	}
}